<?php
 @header("content-type:text/html;charset=utf-8");
 @header("Access-Control-Allow-Origin:*");
 mysql_connect("localhost:3306","root","root");
 mysql_select_db("1904");
 mysql_query("set character set utf8");
 mysql_query("set names utf8");
 $key=$_GET["name"];
 $pwd=$_GET["pwd"];
//  echo $key,$pwd;
 $result=mysql_query("select * from userinfo where user_name='$key' and user_pwd='$pwd' or user_phone='$key' and user_pwd='$pwd'");
//  print_r( mysql_fetch_row($result));//数组不能用echo打印
  $arr=array();
 if($item=mysql_fetch_row($result)){
    //  查找出对应的用户
    // print_r($item);
     $arr["status"]=true;
     $arr["msg"]="登录成功"; 
     $arr["user"]=$item[1];
     $arr["pwd"]=$item[2];
     $arr["id"]=$item[0];
 }
 else{
     $arr["status"]=false;
     $arr["msg"]="密码错误";
 }
 echo json_encode($arr);
?>